<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./promise.js"></script>
</head>
<body>
    <h1>自定义Promise--同步修改状态then方法返回值</h1>
    <script>
        // 使用自定义的Promise
        const p = new Promise((resolve, reject)=>{
            //resolve("成功了");
            throw "出错了";
        });

        console.log(p);
        // 使用promise
        p.then(v => {
            console.log("ok01",v);
           return "aa";
        },r => {
            console.log("err01",r);
            //throw "error";
        }).then(v => {
            console.log("ok02",v);
            return new Promise((resolve, reject)=>{
                //resolve("成功了");
                reject("失败")
            });
        },r => {
            console.log("err02",r);
        }).then(v => {
            console.log("ok03",v);
        },r => {
            console.log("err03",r);
        })

    </script>
</body>
</html>